
import { observer } from "mobx-react";
import React from 'react';
import { WeaTableEdit } from 'ecCom';
import { toJS } from 'mobx';
@observer
export default class StageList extends React.Component {

    constructor(props) {
        super(props);
    }

    render() {
        const { contentStore } = this.props;
        const { stageInfo : { stageColumns, stageColumnDatas, selectedDatas, selectedRowKeys,canedit }, onRowSelect, onChange } = contentStore;
        return ( 
            <div >
                {stageColumns && stageColumns.length>0 &&<WeaTableEdit ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEdit@tdhnss`}
                    draggable={canedit}
                    showTitle={false}
                    columns={toJS(stageColumns)}
                    datas={stageColumnDatas}
                    onChange={onChange}
                    onRowSelect={onRowSelect}
                    selectedData={selectedDatas}
                    selectedRowKeys={selectedRowKeys}
                    getRowSelection={this.getRowSelection}
                    copyFilterProps={["id"]}
                    rowKey={"id"}
                    ref={el => {this.tableEdit = el}}
                />}
            </div>)

    }

    getRowSelection = (rowSelection) => {
        const { contentStore } = this.props;
        const { stageInfo : { canedit }} = contentStore;
        let sel = { ...rowSelection };
        sel.getCheckboxProps = (record) => {
            return { disabled: record.candel == false };
        }
        return canedit ? sel:null;
    }
    
}

